# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This class is auto generated by the swagger code generator program.
# https://github.com/swagger-api/swagger-codegen.git
# Do not edit the class manually.

defmodule GoogleApi.Partners.V2.Api.Companies do
  @moduledoc """
  API calls for all endpoints tagged `Companies`.
  """

  alias GoogleApi.Partners.V2.Connection
  alias GoogleApi.Gax.{Request, Response}

  @doc """
  Gets a company.

  ## Parameters

  - connection (GoogleApi.Partners.V2.Connection): Connection to server
  - company_id (String.t): The ID of the company to retrieve.
  - optional_params (KeywordList): [optional] Optional parameters
    - :$.xgafv (String.t): V1 error format.
    - :access_token (String.t): OAuth access token.
    - :alt (String.t): Data format for response.
    - :callback (String.t): JSONP
    - :fields (String.t): Selector specifying which fields to include in a partial response.
    - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
    - :oauth_token (String.t): OAuth 2.0 token for the current user.
    - :prettyPrint (boolean()): Returns response with indentations and line breaks.
    - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
    - :upload_protocol (String.t): Upload protocol for media (e.g. \&quot;raw\&quot;, \&quot;multipart\&quot;).
    - :uploadType (String.t): Legacy upload protocol for media (e.g. \&quot;media\&quot;, \&quot;multipart\&quot;).
    - :address (String.t): The address to use for sorting the company&#39;s addresses by proximity. If not given, the geo-located address of the request is used. Used when order_by is set.
    - :currencyCode (String.t): If the company&#39;s budget is in a different currency code than this one, then the converted budget is converted to this currency code.
    - :orderBy (String.t): How to order addresses within the returned company. Currently, only &#x60;address&#x60; and &#x60;address desc&#x60; is supported which will sorted by closest to farthest in distance from given address and farthest to closest distance from given address respectively.
    - :requestMetadata.experimentIds ([String.t]): Experiment IDs the current request belongs to.
    - :requestMetadata.locale (String.t): Locale to use for the current request.
    - :requestMetadata.partnersSessionId (String.t): Google Partners session ID.
    - :requestMetadata.trafficSource.trafficSourceId (String.t): Identifier to indicate where the traffic comes from. An identifier has multiple letters created by a team which redirected the traffic to us.
    - :requestMetadata.trafficSource.trafficSubId (String.t): Second level identifier to indicate where the traffic comes from. An identifier has multiple letters created by a team which redirected the traffic to us.
    - :requestMetadata.userOverrides.ipAddress (String.t): IP address to use instead of the user&#39;s geo-located IP address.
    - :requestMetadata.userOverrides.userId (String.t): Logged-in user ID to impersonate instead of the user&#39;s ID.
    - :view (String.t): The view of &#x60;Company&#x60; resource to be returned. This must not be &#x60;COMPANY_VIEW_UNSPECIFIED&#x60;.

  ## Returns

  {:ok, %GoogleApi.Partners.V2.Model.GetCompanyResponse{}} on success
  {:error, info} on failure
  """
  @spec partners_companies_get(Tesla.Env.client(), String.t(), keyword()) ::
          {:ok, GoogleApi.Partners.V2.Model.GetCompanyResponse.t()} | {:error, Tesla.Env.t()}
  def partners_companies_get(connection, company_id, optional_params \\ [], opts \\ []) do
    optional_params_config = %{
      :"$.xgafv" => :query,
      :access_token => :query,
      :alt => :query,
      :callback => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :upload_protocol => :query,
      :uploadType => :query,
      :address => :query,
      :currencyCode => :query,
      :orderBy => :query,
      :"requestMetadata.experimentIds" => :query,
      :"requestMetadata.locale" => :query,
      :"requestMetadata.partnersSessionId" => :query,
      :"requestMetadata.trafficSource.trafficSourceId" => :query,
      :"requestMetadata.trafficSource.trafficSubId" => :query,
      :"requestMetadata.userOverrides.ipAddress" => :query,
      :"requestMetadata.userOverrides.userId" => :query,
      :view => :query
    }

    request =
      Request.new()
      |> Request.method(:get)
      |> Request.url("/v2/companies/{companyId}", %{
        "companyId" => URI.encode_www_form(company_id)
      })
      |> Request.add_optional_params(optional_params_config, optional_params)

    connection
    |> Connection.execute(request)
    |> Response.decode(opts ++ [struct: %GoogleApi.Partners.V2.Model.GetCompanyResponse{}])
  end

  @doc """
  Creates an advertiser lead for the given company ID.

  ## Parameters

  - connection (GoogleApi.Partners.V2.Connection): Connection to server
  - company_id (String.t): The ID of the company to contact.
  - optional_params (KeywordList): [optional] Optional parameters
    - :$.xgafv (String.t): V1 error format.
    - :access_token (String.t): OAuth access token.
    - :alt (String.t): Data format for response.
    - :callback (String.t): JSONP
    - :fields (String.t): Selector specifying which fields to include in a partial response.
    - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
    - :oauth_token (String.t): OAuth 2.0 token for the current user.
    - :prettyPrint (boolean()): Returns response with indentations and line breaks.
    - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
    - :upload_protocol (String.t): Upload protocol for media (e.g. \&quot;raw\&quot;, \&quot;multipart\&quot;).
    - :uploadType (String.t): Legacy upload protocol for media (e.g. \&quot;media\&quot;, \&quot;multipart\&quot;).
    - :body (CreateLeadRequest): 

  ## Returns

  {:ok, %GoogleApi.Partners.V2.Model.CreateLeadResponse{}} on success
  {:error, info} on failure
  """
  @spec partners_companies_leads_create(Tesla.Env.client(), String.t(), keyword()) ::
          {:ok, GoogleApi.Partners.V2.Model.CreateLeadResponse.t()} | {:error, Tesla.Env.t()}
  def partners_companies_leads_create(connection, company_id, optional_params \\ [], opts \\ []) do
    optional_params_config = %{
      :"$.xgafv" => :query,
      :access_token => :query,
      :alt => :query,
      :callback => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :upload_protocol => :query,
      :uploadType => :query,
      :body => :body
    }

    request =
      Request.new()
      |> Request.method(:post)
      |> Request.url("/v2/companies/{companyId}/leads", %{
        "companyId" => URI.encode_www_form(company_id)
      })
      |> Request.add_optional_params(optional_params_config, optional_params)

    connection
    |> Connection.execute(request)
    |> Response.decode(opts ++ [struct: %GoogleApi.Partners.V2.Model.CreateLeadResponse{}])
  end

  @doc """
  Lists companies.

  ## Parameters

  - connection (GoogleApi.Partners.V2.Connection): Connection to server
  - optional_params (KeywordList): [optional] Optional parameters
    - :$.xgafv (String.t): V1 error format.
    - :access_token (String.t): OAuth access token.
    - :alt (String.t): Data format for response.
    - :callback (String.t): JSONP
    - :fields (String.t): Selector specifying which fields to include in a partial response.
    - :key (String.t): API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
    - :oauth_token (String.t): OAuth 2.0 token for the current user.
    - :prettyPrint (boolean()): Returns response with indentations and line breaks.
    - :quotaUser (String.t): Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
    - :upload_protocol (String.t): Upload protocol for media (e.g. \&quot;raw\&quot;, \&quot;multipart\&quot;).
    - :uploadType (String.t): Legacy upload protocol for media (e.g. \&quot;media\&quot;, \&quot;multipart\&quot;).
    - :address (String.t): The address to use when searching for companies. If not given, the geo-located address of the request is used.
    - :companyName (String.t): Company name to search for.
    - :gpsMotivations ([String.t]): List of reasons for using Google Partner Search to get companies.
    - :industries ([String.t]): List of industries the company can help with.
    - :languageCodes ([String.t]): List of language codes that company can support. Only primary language subtags are accepted as defined by &lt;a href&#x3D;\&quot;https://tools.ietf.org/html/bcp47\&quot;&gt;BCP 47&lt;/a&gt; (IETF BCP 47, \&quot;Tags for Identifying Languages\&quot;).
    - :maxMonthlyBudget.currencyCode (String.t): The 3-letter currency code defined in ISO 4217.
    - :maxMonthlyBudget.nanos (integer()): Number of nano (10^-9) units of the amount. The value must be between -999,999,999 and +999,999,999 inclusive. If &#x60;units&#x60; is positive, &#x60;nanos&#x60; must be positive or zero. If &#x60;units&#x60; is zero, &#x60;nanos&#x60; can be positive, zero, or negative. If &#x60;units&#x60; is negative, &#x60;nanos&#x60; must be negative or zero. For example $-1.75 is represented as &#x60;units&#x60;&#x3D;-1 and &#x60;nanos&#x60;&#x3D;-750,000,000.
    - :maxMonthlyBudget.units (String.t): The whole units of the amount. For example if &#x60;currencyCode&#x60; is &#x60;\&quot;USD\&quot;&#x60;, then 1 unit is one US dollar.
    - :minMonthlyBudget.currencyCode (String.t): The 3-letter currency code defined in ISO 4217.
    - :minMonthlyBudget.nanos (integer()): Number of nano (10^-9) units of the amount. The value must be between -999,999,999 and +999,999,999 inclusive. If &#x60;units&#x60; is positive, &#x60;nanos&#x60; must be positive or zero. If &#x60;units&#x60; is zero, &#x60;nanos&#x60; can be positive, zero, or negative. If &#x60;units&#x60; is negative, &#x60;nanos&#x60; must be negative or zero. For example $-1.75 is represented as &#x60;units&#x60;&#x3D;-1 and &#x60;nanos&#x60;&#x3D;-750,000,000.
    - :minMonthlyBudget.units (String.t): The whole units of the amount. For example if &#x60;currencyCode&#x60; is &#x60;\&quot;USD\&quot;&#x60;, then 1 unit is one US dollar.
    - :orderBy (String.t): How to order addresses within the returned companies. Currently, only &#x60;address&#x60; and &#x60;address desc&#x60; is supported which will sorted by closest to farthest in distance from given address and farthest to closest distance from given address respectively.
    - :pageSize (integer()): Requested page size. Server may return fewer companies than requested. If unspecified, server picks an appropriate default.
    - :pageToken (String.t): A token identifying a page of results that the server returns. Typically, this is the value of &#x60;ListCompaniesResponse.next_page_token&#x60; returned from the previous call to ListCompanies.
    - :requestMetadata.experimentIds ([String.t]): Experiment IDs the current request belongs to.
    - :requestMetadata.locale (String.t): Locale to use for the current request.
    - :requestMetadata.partnersSessionId (String.t): Google Partners session ID.
    - :requestMetadata.trafficSource.trafficSourceId (String.t): Identifier to indicate where the traffic comes from. An identifier has multiple letters created by a team which redirected the traffic to us.
    - :requestMetadata.trafficSource.trafficSubId (String.t): Second level identifier to indicate where the traffic comes from. An identifier has multiple letters created by a team which redirected the traffic to us.
    - :requestMetadata.userOverrides.ipAddress (String.t): IP address to use instead of the user&#39;s geo-located IP address.
    - :requestMetadata.userOverrides.userId (String.t): Logged-in user ID to impersonate instead of the user&#39;s ID.
    - :services ([String.t]): List of services that the returned agencies should provide. If this is not empty, any returned agency must have at least one of these services, or one of the specializations in the \&quot;specializations\&quot; field.
    - :specializations ([String.t]): List of specializations that the returned agencies should provide. If this is not empty, any returned agency must have at least one of these specializations, or one of the services in the \&quot;services\&quot; field.
    - :view (String.t): The view of the &#x60;Company&#x60; resource to be returned. This must not be &#x60;COMPANY_VIEW_UNSPECIFIED&#x60;.
    - :websiteUrl (String.t): Website URL that will help to find a better matched company. .

  ## Returns

  {:ok, %GoogleApi.Partners.V2.Model.ListCompaniesResponse{}} on success
  {:error, info} on failure
  """
  @spec partners_companies_list(Tesla.Env.client(), keyword()) ::
          {:ok, GoogleApi.Partners.V2.Model.ListCompaniesResponse.t()} | {:error, Tesla.Env.t()}
  def partners_companies_list(connection, optional_params \\ [], opts \\ []) do
    optional_params_config = %{
      :"$.xgafv" => :query,
      :access_token => :query,
      :alt => :query,
      :callback => :query,
      :fields => :query,
      :key => :query,
      :oauth_token => :query,
      :prettyPrint => :query,
      :quotaUser => :query,
      :upload_protocol => :query,
      :uploadType => :query,
      :address => :query,
      :companyName => :query,
      :gpsMotivations => :query,
      :industries => :query,
      :languageCodes => :query,
      :"maxMonthlyBudget.currencyCode" => :query,
      :"maxMonthlyBudget.nanos" => :query,
      :"maxMonthlyBudget.units" => :query,
      :"minMonthlyBudget.currencyCode" => :query,
      :"minMonthlyBudget.nanos" => :query,
      :"minMonthlyBudget.units" => :query,
      :orderBy => :query,
      :pageSize => :query,
      :pageToken => :query,
      :"requestMetadata.experimentIds" => :query,
      :"requestMetadata.locale" => :query,
      :"requestMetadata.partnersSessionId" => :query,
      :"requestMetadata.trafficSource.trafficSourceId" => :query,
      :"requestMetadata.trafficSource.trafficSubId" => :query,
      :"requestMetadata.userOverrides.ipAddress" => :query,
      :"requestMetadata.userOverrides.userId" => :query,
      :services => :query,
      :specializations => :query,
      :view => :query,
      :websiteUrl => :query
    }

    request =
      Request.new()
      |> Request.method(:get)
      |> Request.url("/v2/companies")
      |> Request.add_optional_params(optional_params_config, optional_params)

    connection
    |> Connection.execute(request)
    |> Response.decode(opts ++ [struct: %GoogleApi.Partners.V2.Model.ListCompaniesResponse{}])
  end
end
